package com.fangs.yehwangglobal.ui.activity

import android.os.Bundle
import android.text.TextUtils
import android.view.Menu
import android.view.MenuInflater
import androidx.fragment.app.Fragment
import com.fangs.yehwangglobal.R
import com.fangs.yehwangglobal.base.BaseActivity
import com.fangs.yehwangglobal.databinding.ActivityMainBinding
import com.fangs.yehwangglobal.ui.adapter.BaseFragmentAdapter
import com.fangs.yehwangglobal.ui.fragment.*
import java.util.ArrayList

class MainActivity : BaseActivity<ActivityMainBinding>() {

    override fun afterCreate(savedInstanceState: Bundle?) {
        val mFragments: MutableList<Fragment> = ArrayList()
        mFragments.add(HomeFragment.getInstance())
        mFragments.add(TypeFragment.getInstance())
        mFragments.add(YehwangStyleFragment.getInstance())
        mFragments.add(CartNewFragment.getInstance())
        mFragments.add(UserFragment.getInstance())
        viewBinding?.vp?.setAdapter(BaseFragmentAdapter(supportFragmentManager, mFragments))
        viewBinding?.vp?.setOffscreenPageLimit(5)
        viewBinding?.alphaIndicator?.setViewPager(viewBinding?.vp)
        viewBinding!!.alphaIndicator.setOnTabChangedListner { tabNum ->
            when (tabNum) {
                3, 4 -> if (TextUtils.isEmpty("")) {
                    LoginActivity.readyGo(this)
                    return@setOnTabChangedListner false
                }
            }
            true
        }
    }

}